package com.atguigu.gulimall.seckill.controller;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.seckill.service.SeckillService;
import com.atguigu.gulimall.seckill.to.SeckillSkuRedisTo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ming
 * @create 2022/5/13
 * @description:
 */
@RestController
@Slf4j
public class SeckillController {
    @Autowired
    private SeckillService seckillService;
    /**
     * 返回当前时间可以参与的秒杀商品信息
     * @return
     */
     @GetMapping("/getCurrentSeckillSkus")
    public R getCuuentSeckillSkus(){
         log.info("************调用getCurrentSeckillSkus************");
         List<SeckillSkuRedisTo> vos =  seckillService.getCurrentSeckillSkus();
        return R.ok().setData(vos);
    }
    @GetMapping("/sku/seckill/{skuId}")
    public R getSkuSkillInfo(@PathVariable("skuId")Long skuId){
        SeckillSkuRedisTo vos = seckillService.getSkuSkillInfo(skuId);
         return R.ok().setData(vos);
    }

    
}
